Back to course home
0% completed
Vote For New Content
Meta Hard Problems
Sliding Window Median (hard)
Solution: Sliding Window Median
Alien Dictionary (hard)
Solution: Alien Dictionary
Minimum Window Substring (hard)
Solution: Minimum Window Substring
Best Meeting Point (hard)
Solution: Best Meeting Point
Maximum Sum of 3 Non-Overlapping Subarrays (hard)
Solution: Maximum Sum of 3 Non-Overlapping Subarrays
Making A Large Island (hard)
Solution: Making A Large Island
Basic Calculator (Hard)
Solution: Basic Calculator
Serialize and Deserialize Binary Tree (hard)
Solution: Serialize and Deserialize Binary Tree
Longest Increasing Path in a Matrix (hard)
Solution: Longest Increasing Path in a Matrix
Valid Palindrome III (hard)
Solution: Valid Palindrome III
Number of Substrings Containing All Three Characters (medium)
Problem Statement
Given a string s containing only a, b, and c characters, return the number of substrings containing at least one occurences of a, b and c characters.
Examples
-
Example 1:
- Input:
"abc" - Expected Output:
1 - Justification: The string itself ("abc") is the only substring containing all three characters.
- Input:
-
Example 2:
- Input:
"abbcca" - Expected Output:
5 - Justification: The substrings containing all 3 characters are "abbc", "abbcc", "abbcca", "bbcca", and "bcca".
- Input:
-
Example 3:
- Input:
"ababacb" - Expected Output:
9 - Justification: The substrings containing all 3 characters are "ababac", "babac", "abac", "bac", "ababacb", "babacb", "abacb", "bacb", and "acb".
- Input:
Try it yourself
Try solving this question here:
Java
Saved to Cloud
. . . .
Solution: Missing Element in Sorted Array
Solution: Number of Substrings Containing All Three Characters
Mark as Completed
On this page
Problem Statement
Examples
Try it yourself